package org.yefei.homeworkday12;

import java.util.Scanner;

public class Company {
	/*
	 * 3：公司有公司名称，注册地址，电话，经营范围等属性，公司有很多员工（暂用字符数组表示），公司有招聘员工方法，有输出员工信息方法，以及辞退员工方法。
	 * 用oo的思想模拟
	 */
	public String cName;
	public String zAddress;
	public String phoneNum;
	public String range;
	public String[] workers = new String[19];

	// 1、查看公司信息
	public void showInfo() {
		System.out.println("公司名为" + cName + ",地址" + zAddress);
		System.out.println("电话是" + phoneNum + "经营范围：" + range);
		System.out.println("公司员工信息：");
		for (int i = 0; i < workers.length; i++) {
			if (workers[i] == null)
				break;
			System.out.print(workers[i] + "\t");
		}
		System.out.println();
	}

	// 2、招聘新员工
	public void add(String newWorkers) {
		for (int i = 0; i < workers.length; i++) {
			if (workers[i] == null) {
				workers[i] = newWorkers;
				return;
			}
		}
		System.out.println("位置满了！");
	}

	// 3、辞退员工
	public void dele(int index) {
		if (index >= 0 && index < workers.length) {
			for (int i = index; i < workers.length - 1; i++) {
				workers[i] = workers[i + 1];
			}
			workers[workers.length - 1] = null;
		} else {
			System.out.println("序号超范围！！");
		}

	}
	
//	public void delete(String sname) {
//		for (int i = 0; i < member.length; i++) {
//			if (member[i] != null && member[i].equals(sname)) {
//				member[i] = member[i + 1];
//			}
//			member[member.length - 1] = null;
//		}
//	}

	public static void main(String[] args) {
		Company com = new Company();
		com.cName = "京东科技有限公司";
		com.phoneNum = "8888888";
		com.range = "网购";
		com.zAddress = "北京中关村";
		int choice = 0;
		Scanner in = new Scanner(System.in);
		while (true) {
			System.out.println("1:查看公司及员工信息，2：招新员工，3：辞退员工，9：退出");
			choice = in.nextInt();
			if (choice == 1) {
				com.showInfo();
			} else if (choice == 2) {
				System.out.println("招新员工：");
				String newWorker = in.next();
				com.add(newWorker);
			} else if (choice == 3) {
				System.out.println("辞退员工：");
				int id = in.nextInt() - 1;
					com.dele(id);
			} else if (choice == 9) {
				break;
			} else {
				System.out.println("输入有误！重新输入：");
			}
		}
	}
}
